#define _CRT_SECURE_NO_WARNINGS  1
#include <stdio.h>
void check1(int(*p)[100], int n, int arr[]);
void check2(int(*p)[100], int n, int arr[]);
int main() {
    int n = 0;
    while (scanf("%d", &n) != EOF)
    {
        int question[100][100] = { 0 };
        int arr[100] = { 0 };
        int(*p)[100] = question;
        int n1 = n;
        int a = 0;
        while (n1--) {
            int i = 0;
            int k = 0;
            scanf("%d%d", &a, &k);
            while (question[a][i] != 0) {
                i++;
            }
            while (k--) {
                int m = 0;
                scanf("%d", &m);
                if (m != a) {
                    question[a][i++] = m;
                }
            }
        }
        check1(p, n, arr);
        check2(p, n, arr);
        int s = 0;
        int count = 0;
        for (s = 0; s <= n; s++) {
            if (arr[s] == 1) {
                count++;
            }
        }
        printf("%d\n", count);
        for (s = 0; s <= n; s++) {
            if (arr[s] == 1) {
                printf("%d ", s);
            }
        }
        if (count)
        {
            printf("\n");
        }
    }
    return 0;
}
void check1(int(*p)[100], int n, int arr[]) {
    int i = 0;
    for (i = 0; i < n; i++) {
        int k = 0;
        while (arr[i] == 0 && arr[(*(p + i))[k]] == 0 && (*(p + i))[k] != 0) {
            int j = 0;
            while ((*(p + ((*(p + i))[k])))[j] != 0 && (*(p + ((*(p + i))[k])))[j] != i) {
                j++;
            }
            if ((*(p + ((*(p + i))[k])))[j] == i) {
                arr[i] = 1;
                arr[(*(p + i))[k]] = 1;
            }
            k++;
        }
    }
}
void check2(int(*p)[100], int n, int arr[]) {
    int i = 0;
    while (1)
    {
        int j = 0;
        while ((*(p + i))[j] != 0)
        {
            if (arr[(*(p + i))[j]] == 1)
            {
                arr[i]++;
            }
            j++;
        }
        if (arr[i] >= 2)
        {
            arr[i] = 1;
        }
        else
        {
            arr[i] = 0;
        }
        i++;
        if (i > n)
        {
            break;
        }
    }
}